const book = E = {
	page() {
		let _tbody = $('#_tbody');
		$.ajax({
			url: url.path + 'dingdan/onese',
			type: 'get',
			data: {
				uid: localStorage.getItem("uid"),
				wid: ""
			},
			dataType: 'json',
			success: function(res) {
				console.log(res);
				if (res.code == 200) {
					_tbody.empty(); // 将容器清空
					let list = res.data;

					$(list).each(function(i, e) {
						if (e.state == 1) {
							state = '待派单';
							let _tds = $(`
							<div class="workorder-card position-relative">
										<div class="workorder-status"> ` + state + ` </div>
											<div class="d-flex justify-content-between align-items-start">
												<div>
													<span> 工单编号：</span>
													<span class="text-secondary">` + e.dno + `</span>
													<i class="bi bi-share ms-2"></i>
												</div>
											</div>
													<p class="my-1">维修日期：<span class="text-primary">` + E.timestampToDate(e.date) + `</span></p>
													<p class="my-1">故障位置：<span class="text-dark">` + e.address + `</span></p>
													<p class="my-1">联系人：<span class="text-dark">` + e.lxrname + `</span></p>
													<p class="my-1">联系电话：<span class="text-dark">` + e.lxrphone + `</span></p>
													<p class="my-1">故障描述：<span class="text-dark">` + e.description + `</span></p>
													<div class="mt-2 d-flex gap-2">
												<button class="btn btn-outline-secondary btn-sm"> 取消工单 </button>
												
										</div>
							</div>
							    `)
							_tds.click(function() {
								location.href = "DPD.html?did=" + e.id;
							})
							_tbody.append(_tds);
						}


					});
				}
			}
		});
	},
	timestampToDate(timestamp) {
		const date = new Date(timestamp); // 将时间戳转换为Date对象
		const options = {
			year: 'numeric',
			month: 'long',
			day: 'numeric'
		}; // 定义日期格式
		return new Intl.DateTimeFormat('zh-CN', options).format(date); // 使用Intl.DateTimeFormat进行格式化
	}
}
$(function() {
	E.page();
})